<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Sifteo SDK: audio.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-style-overrides.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<center>
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Sifteo SDK" src="sdk_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">v1.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</center>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Home</span></a></li>
      <li><a href="pages.html"><span>Guides</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_12cda917fe1d7c8b4e7d2501bb3636e4.html">sdk</a></li><li class="navelem"><a class="el" href="dir_2f23e30b638d6a5f333babd9a5d183e1.html">include</a></li><li class="navelem"><a class="el" href="dir_d5ace589187da7c83c1a7507ec9fbbef.html">sifteo</a></li><li class="navelem"><a class="el" href="dir_9f7c4e3b7feb35fe458a50f9a0128960.html">asset</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">asset/audio.h</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> * This file is part of the public interface to the Sifteo SDK.</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * Copyright &lt;c&gt; 2012 Sifteo, Inc. All rights reserved.</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;</div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor"></span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment">/*</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * This header needs to work in both userspace and non-userspace builds.</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> */</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;sifteo/abi.h&gt;</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="keyword">namespace </span>Sifteo {</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_audio.html">   31</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct_sifteo_1_1_asset_audio.html" title="An audio asset, using any supported compression codec.">AssetAudio</a> {</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    _SYSAudioModule sys;</div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div>
<div class="line"><a name="l00039"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_audio.html#a99caa7d09c00d633d0280eeafc017554">   39</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_asset_audio.html#a99caa7d09c00d633d0280eeafc017554" title="Return the default speed for this audio asset, in samples per second.">speed</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;        <span class="keywordflow">return</span> sys.sampleRate;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    }</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div>
<div class="line"><a name="l00055"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_audio.html#ae01f4b5e1d6359e6047674d00a43830f">   55</a></span>&#160;    <span class="keyword">static</span> <a class="code" href="struct_sifteo_1_1_asset_audio.html" title="An audio asset, using any supported compression codec.">AssetAudio</a> <a class="code" href="struct_sifteo_1_1_asset_audio.html#ae01f4b5e1d6359e6047674d00a43830f" title="Create an AssetAudio object programmatically, from uncompressed PCM data.">fromPCM</a>(<span class="keyword">const</span> int16_t *samples, <span class="keywordtype">unsigned</span> numSamples)</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    {</div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        <span class="keyword">const</span> <a class="code" href="struct_sifteo_1_1_asset_audio.html" title="An audio asset, using any supported compression codec.">AssetAudio</a> result = {{</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;            <span class="comment">/* sampleRate  */</span>  0,</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;            <span class="comment">/* loopStart   */</span>  0,</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;            <span class="comment">/* loopEnd     */</span>  numSamples,</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;            <span class="comment">/* loopType    */</span>  _SYS_LOOP_REPEAT,</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;            <span class="comment">/* type        */</span>  _SYS_PCM,</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;            <span class="comment">/* volume      */</span>  _SYS_AUDIO_DEFAULT_VOLUME,</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;            <span class="comment">/* dataSize    */</span>  numSamples * <span class="keyword">sizeof</span> samples[0],</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;            <span class="comment">/* pData       */</span>  <span class="keyword">reinterpret_cast&lt;</span>uintptr_t<span class="keyword">&gt;</span>(samples),</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;        }};</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;        <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    }</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div>
<div class="line"><a name="l00072"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_audio.html#ab08a3ed503b8b71fb597050593078f0c">   72</a></span>&#160;    <span class="keyword">static</span> <a class="code" href="struct_sifteo_1_1_asset_audio.html" title="An audio asset, using any supported compression codec.">AssetAudio</a> <a class="code" href="struct_sifteo_1_1_asset_audio.html#ab08a3ed503b8b71fb597050593078f0c" title="Templatized version of fromPCM(), for fixed-size sample arrays.">fromPCM</a>(<span class="keyword">const</span> T &amp;samples) {</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;        <span class="keywordflow">return</span> <a class="code" href="struct_sifteo_1_1_asset_audio.html#ae01f4b5e1d6359e6047674d00a43830f" title="Create an AssetAudio object programmatically, from uncompressed PCM data.">fromPCM</a>(&amp;samples[0], <a class="code" href="group__macros.html#gaa1394a41d43c0f3fd30febe41c7bb340">arraysize</a>(samples));</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    }</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;};</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div>
<div class="line"><a name="l00093"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_tracker.html">   93</a></span>&#160;<span class="keyword">struct </span><a class="code" href="struct_sifteo_1_1_asset_tracker.html" title="A Tracker module, converted from XM format by stir">AssetTracker</a> {</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    _SYSXMSong song;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;</div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_tracker.html#a8d109238c0f98961a72dea0bf160adbe">   97</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_asset_tracker.html#a8d109238c0f98961a72dea0bf160adbe" title="The number of channels used by this tracker module.">numChannels</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;        <span class="keywordflow">return</span> song.nChannels;</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    }</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;</div>
<div class="line"><a name="l00102"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_tracker.html#a52d2b2756b788874c1190a63a9a46125">  102</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_asset_tracker.html#a52d2b2756b788874c1190a63a9a46125" title="The number of patterns in this tracker module.">numPatterns</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;        <span class="keywordflow">return</span> song.nPatterns;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    }</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;</div>
<div class="line"><a name="l00107"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_tracker.html#a1739ba521a9f35f256d05af1c1ec737c">  107</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_asset_tracker.html#a1739ba521a9f35f256d05af1c1ec737c" title="The number of instruments in this tracker module.">numInstruments</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        <span class="keywordflow">return</span> song.nInstruments;</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    }</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;</div>
<div class="line"><a name="l00112"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_tracker.html#ac951e6aaa5c317f402befbcca0d9325d">  112</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_asset_tracker.html#ac951e6aaa5c317f402befbcca0d9325d" title="This tracker module&#39;s default tempo (ticks)">tempo</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;        <span class="keywordflow">return</span> song.tempo;</div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;    }</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;</div>
<div class="line"><a name="l00117"></a><span class="lineno"><a class="code" href="struct_sifteo_1_1_asset_tracker.html#ab6fc6a696a1c2454c52cde0d329413b3">  117</a></span>&#160;    <span class="keywordtype">unsigned</span> <a class="code" href="struct_sifteo_1_1_asset_tracker.html#ab6fc6a696a1c2454c52cde0d329413b3" title="This tracker module&#39;s default beats per minute (notes)">bpm</a>()<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;        <span class="keywordflow">return</span> song.bpm;</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;    }</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;};</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;};  <span class="comment">// namespace Sifteo</span></div>
</div><!-- fragment --></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
    <hr class="footer"/>
    <address class="footer">
        <p><a href="http://sifteo.com">Sifteo</a> SDK v1.0.0 <small>(see <a href="https://developers.sifteo.com/sifteosdk">all versions</a>)</small></p>
        <p>Last updated Wed Mar 27 2013, by <a href="http://www.stack.nl/~dimitri/doxygen">Doxygen</a></p>
    </address>
</body>
</html>
